<?php

class FacebookAutoLoginBehavior extends CBehavior
{
	/**
	 * @return array the events and event handler for this behavior.
	 */
	public function events()
	{
		return array(
			'onBeginRequest'=>'beginRequest',
		);
	}

	/**
	 * Actions to take before starting the request.
	 */
	public function beginRequest()
	{
		// Do the Facebook auto-login magic for guests.
		if (Yii::app()->user->isGuest)
			Yii::app()->fb->login();
	}
}